<template>
    <div class="table-list" style="margin-top: 20px;">
        <el-table
            :data="powerData"
            :height="oHeight"
            row-key="menu_id"
            border
            default-expand-all
            :tree-props="{children: 'child'}"
        >
			<el-table-column align="left" prop="menu_name" label="名称" min-width="180"></el-table-column>
			<el-table-column align="center" prop="sort" label="排序" min-width="80"></el-table-column>
			<el-table-column align="center" prop="description" label="路由名称" min-width="180"></el-table-column>
			<el-table-column align="center" prop="is_show_tab" label="是否显示公共tab" min-width="120" #default="{row}">
				<el-button :type="row.is_show_tab==='0'?'danger':'primary'">{{row.is_show_tab==='0'?'隐藏':'展示'}}</el-button>
			</el-table-column>
			<el-table-column align="center" prop="in_page" label="位置" min-width="120" #default="{row}">
				{{row.in_page==0?"":"页面中"}}
			</el-table-column>
            <el-table-column align="center" prop="is_choose" label="操作" width="200" #default="{row}">
                <el-button type="primary" @click="showContent('edit',row)">编辑</el-button>
                <el-button type="danger" @click="delMenu(row)">删除</el-button>
            </el-table-column>
        </el-table>
        <div class="bottom">
            <div class="btn-group">
                <el-button type="primary" class="btn-bottom" @click="showContent('add')">新增</el-button>
                <!-- <el-button type="primary" class="btn-bottom" @click="expertData">导出检索数据</el-button> -->
            </div>
            <!--分页部分-->
            <div class="paginationOne">
                <!-- <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="searchContent.currentPage"
                    :page-sizes="[10, 20, 50, 100]"
                    :page-size="searchContent.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total*1"
                ></el-pagination> -->
            </div>
        </div>
        <edit-drawer ref="editDrawer" :powerData="powerData"></edit-drawer>
    </div>
</template>
<script>
import { resize } from "@/common/js/height.js";
import editDrawer from './show-edit-drawer';
import { dateFormatter, objScreen } from "@/common/js/util";
export default {
    components: { editDrawer },
    data() {
        return {
            powerData: [],
            oHeight: "0"
        };
    },
    created() {
        this.getListData();
        // this.default_data();
    },
    methods: {
        default_data() {
        },
        getListData() {
            this.$http.post("/admin/auth/index.php?act=adminMenu&op=menuList&parent_menu_id=0").then(res => {
                if (res.code == 1) {
                    this.powerData = res.data;
                } else {
                    this.$message.error(res.msg)
                }
            }).catch(err => {
                this.$message.error(err)
            })
        },
        showContent(type, row) {
            if (type === 'add') {
                this.$refs.editDrawer.show_dialog_fn('add', row)
            } else {
                this.$refs.editDrawer.show_dialog_fn('edit', row)
            }
        },
        delMenu({ menu_id }) {
            if (!confirm('确定要删除?')) {
                return
            }
            this.$http.post(`/admin/auth/index.php?act=adminMenu&op=delMenu&menu_id=${menu_id}`).then(res => {
                if (res.code == 1) {
					this.$message.success(res.msg)
					this.getListData();
                } else {
                    this.$message.error(res.msg)
                }
            }).catch(err => {
                this.$message.error(err)
            })
        },
    },
    mounted() {
        resize(this)
    },
};
</script>
<style lang="scss" scoped>
.bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.search-content-input {
    width: 200px;
}
</style>